package com.ArrayListTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        int count=0;
        Random r = new Random();
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        for (int i=0;i<5;i++){
            int s =r.nextInt(10)+1;
            arrayList.add(s);
        }
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入：");
        int x = sc.nextInt();
        for (int i =0;i<arrayList.size();i++){
            if (arrayList.get(i).toString().equals(x+"")){
                count++;
            }
        }
        System.out.println("该数在集合中出现的次数为："+count+"次");
        arrayList.forEach((e)->{
            System.out.println(e.toString());
        });
    }
}
